home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
c
/
cppmatrx.zip
/
MATRIX.ZIP
/
MATRIX2.C
< prev
next >
Wrap
Text File
|
1991-01-27
|
1KB
|
77 lines
#include <iostream.h>
typedef double m_line [4];
typedef m_line m_type [4];
class matrix {
m_type m;
public:
matrix (void);
~matrix (void);
void print_matrix (void);
matrix operator+(matrix&, matrix&);
};
matrix matrix::operator+(matrix arg1)
{
matrix sum;
int i,j;
for (i=0; i<4; i++)
for (j=0; j<4; j++)
sum.m [i][j] = m [i][j] + arg1.m [i][j];
return sum;
}
void matrix::print_matrix (void)
{
int i,j;
cout << '\n';
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++)
cout << m [i][j];
cout << '\n';
}
cout << '\n';
}
matrix::matrix (void)
{
int i,j;
// m = new m_line [4];
for (i = 0; i < 4; i++)
for (j = 0; j < 4; j++)
m [i][j] = 1;
}
matrix::~matrix (void)
{
// delete m [4];
}
main (void)
{
matrix matrix1, matrix2;
(matrix1+matrix2).print_matrix ();
return 0;
}